package com.appspot.igo8poi.service;

import com.appspot.igo8poi.model.bean.UserInfo;
import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;

public class UserManager {

	private static UserManager userManager = new UserManager();

	private UserManager() {
	}

	public static UserManager getInstance() {
		return userManager;
	}

	public UserInfo getCurrentUser() {
		UserService userService = UserServiceFactory.getUserService();
		User user = userService.getCurrentUser();
		return null == user ? null : new UserInfo(user.getUserId(), user.getEmail(), user.getNickname());
	}

	public boolean isUserAdmin() {
		UserService userService = UserServiceFactory.getUserService();
		return  userService.isUserAdmin();
	}

	public String createLoginUrl(String requestUri) {
		UserService userService = UserServiceFactory.getUserService();
		return userService.createLoginURL(requestUri);
	}

}
